function correspOverlapDisplay(matches, ttype, im1, im2, output)

% Get the transform
tform = cp2tform((matches([1 2],:))', (matches([3 4],:))', ttype);

% Apply the transform to image 1
[im1trans xdata ydata] = imtransform(im1, tform, 'XYScale',1);

[n o b] = size(im1trans);
[l m z] = size(im2);

if(xdata(1)<0)
	xdisp = -xdata(1) + 1;
    xdisp = round(xdisp);
    
	if(ydata(1)<0)
        ydisp = round(-ydata(1) + 1);
        imgsizex = max(n, l+ydisp-1);
        imgsizey = max(o, m+xdisp-1);
 
        canvas = uint8(zeros(imgsizex, imgsizey,3));
        canvas1 = uint8(zeros(imgsizex, imgsizey,3));
        canvas2 = uint8(zeros(imgsizex, imgsizey,3));
     
        canvas1(1:(n), 1:o, 1:z) = im1trans;
        canvas2(ydisp:(l+ydisp-1), xdisp:(m+xdisp-1), 1:z)= im2;
 
    else
        ydisp = round(1+ydata(1));
        imgsizex = max(n+ydisp-1, l);
        imgsizey = max(o, xdisp+m-1);
 
        canvas = uint8(zeros(imgsizex, imgsizey,3));
        canvas1 = uint8(zeros(imgsizex, imgsizey,3));
        canvas2 = uint8(zeros(imgsizex, imgsizey,3));
     
        canvas1(ydisp:(ydisp+n-1), 1:(o), 1:z) = im1trans;
        canvas2(1:(l), xdisp:(xdisp+m-1), 1:z)= im2;
    end    
    
else
	xdisp = xdata(1) + 1;
	xdisp = round(xdisp);
    
	if(ydata(1)<0)
        ydisp = round(-ydata(1) + 1);
        imgsizex = max(n, l+ydisp-1);
        imgsizey = max(o+xdisp-1, m);
 
        canvas = uint8(zeros(imgsizex, imgsizey,3));
        canvas1 = uint8(zeros(imgsizex, imgsizey,3));
        canvas2 = uint8(zeros(imgsizex, imgsizey,3));
     
        canvas1(1:(n), xdisp:(o+xdisp-1), 1:z) = im1trans;
        canvas2(ydisp:(ydisp+l-1), 1:(m), 1:z)= im2;
 
    else
        ydisp = round(1+ydata(1));
        imgsizex = max(n+ydisp-1, l);
        imgsizey = max(o+xdisp-1, m);
 
        canvas = uint8(zeros(imgsizex, imgsizey,3));
        canvas1 = uint8(zeros(imgsizex, imgsizey,3));
        canvas2 = uint8(zeros(imgsizex, imgsizey,3));
     
        canvas1(ydisp:(n+ydisp-1), xdisp:(xdisp+o-1), 1:z) = im1trans;
        canvas2(1:(l), 1:(m), 1:z)= im2;
	end    
end
    canvassub = imsubtract(canvas1, canvas2);
    canvas = imadd(canvassub,canvas2);
    imwrite(canvas, output);
    imshow(canvas);
end

